
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
public class Music {

    /**
     * 落子声音
     */
    public void putVoice() {
        try {
            InputStream sound = this.getClass().getResourceAsStream(GameUtil.choice[0]);
            assert sound != null;
            AudioStream as= new AudioStream(sound);
            AudioPlayer.player.start(as);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获胜声音
     */
    public void winVoice() {
        try {
            InputStream sound = this.getClass().getResourceAsStream(GameUtil.choice[1]);
            assert sound != null;
            AudioStream as= new AudioStream(sound);
            AudioPlayer.player.start(as);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 失败声音
     */
    public void lostVoice() {
        try {
            InputStream sound = this.getClass().getResourceAsStream(GameUtil.choice[2]);
            assert sound != null;
            AudioStream as= new AudioStream(sound);
            AudioPlayer.player.start(as);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

